package com.company.dao;

import com.company.pojo.Student;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

/**
 * @ClassName StudentDao
 * @Description
 */
@Repository("studentDao")
public class StudentDao {

    public Student get(JdbcTemplate jdbcTemplate, Integer id) {
        String sql = "SELECT S_ID, S_NAME, S_AGE FROM STUDENT WHERE S_ID = ? ";
        RowMapper<Student> rowMapper = new BeanPropertyRowMapper(Student.class);
        Student student = jdbcTemplate.queryForObject(sql, rowMapper, id);
        return student;
    }
}
